package co.kr.hanbitedu.android.sample;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.AnalogClock;
import android.widget.Button;
import android.widget.TabHost;

public class DynamicTabDemo extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        final TabHost tabs=(TabHost)findViewById(R.id.tabhost);
		
		tabs.setup();
		
		TabHost.TabSpec spec=tabs.newTabSpec("buttontab");
		spec.setContent(R.id.buttontab);
		spec.setIndicator("Button");
		tabs.addTab(spec);
		
		tabs.setCurrentTab(0);
	
		Button btn=(Button)tabs.getCurrentView().findViewById(R.id.buttontab);
		
		btn.setOnClickListener(new View.OnClickListener() {
			public void onClick(View view) {
				TabHost.TabSpec spec=tabs.newTabSpec("tag1");
				
				spec.setContent(new TabHost.TabContentFactory() {
					public View createTabContent(String tag) {
						return(new AnalogClock(DynamicTabDemo.this));
					}
				});
				spec.setIndicator("Clock");
				tabs.addTab(spec);
			}
		});
    }
}